import { defineConfig } from 'dumi';
import proxy from '@pxxtech/config/proxy';

// Object.defineProperty(RegExp.prototype, 'toJSON', {
//   value: RegExp.prototype.toString,
// });

export default defineConfig({
  title: '平行线',
  hash: true,
  plugins: ['./plugins/auto-export'],
  proxy: proxy('https://dev.pxxtech.com'),
  mode: 'site',
  favicon: '/favicon.ico',
  logo: '/logo.png',
  outputPath: 'docs-dist',
  theme: {
    '@pxx-hd': '1', //改为pxx-hd  预防以后冲突
    '@pxx-hdx': '@pxx-hd*1px',
    '@pxx-prefix': 'pxx',
    '@pxxm-prefix': 'pxxm',
    '@html-selector': 'html', //为各种各样的小程序准备
  },
  alias: {
    demos: process.cwd() + '/src/demos/index.ts',
    '@tarojs/components$': '@tarojs/components-react/index',
    // TODO 暂时通过 alias 修复 linaria 在 umi脚手架 下的无效化
    '@linaria/react$': process.cwd() + '/src/styled-components/index.ts',
    '@tarojs/taro': '@pxxtech/tarojs',
  },
  scripts: ['https://ssl.captcha.qq.com/TCaptcha.js'],
  // headScripts: [
  //   `https://prod-1302801272.cos.ap-guangzhou.myqcloud.com/assets/js/react.production.min.js`,
  //   `https://prod-1302801272.cos.ap-guangzhou.myqcloud.com/assets/js/react-dom.production.min.js`,
  // ],
  publicPath: process.env.NODE_ENV === 'production' ? '/next/' : '/',
  history: { type: 'hash' },
  navs: {
    'zh-CN': [
      null,
      { title: 'Gitee', path: 'https://gitee.com/pxx-design/pxx-design/next' },
    ],
    'en-US': [
      null,
      { title: 'Gitee', path: 'https://gitee.com/pxx-design/pxx-design/next' },
    ],
  },
  extraBabelPlugins: [
    [
      'import',
      {
        libraryName: 'antd',
        style: true,
      },
      'antd',
    ],
    [
      'import',
      {
        libraryName: '@pxxtech/component',
        style: true,
      },
      'component',
    ],
    [
      'pxx-import',
      {
        libraryName: '@pxxtech/web',
        style: true,
      },
      'web',
    ],
    [
      'pxx-import',
      {
        libraryName: '@pxxtech/mobile',
        style: true,
      },
      'mobile',
    ],
  ],
  // mfsu: {},
  webpack5: {},
  chainWebpack(chain, webpack) {
    chain.merge({
      optimization: {
        // 开发模式下开启 Tree Shaking
        sideEffects: true,
      },
    });
  },
});
